<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>


        var time1 = new Date(2021, 1, 23, 11, 22, 18)
        var time2 = new Date(2021, 1, 25, 3, 45, 36)

        function time(time1, time2) {
            var ms1 = time1.getTime();
            var ms2 = time2.getTime();

            var sub = Math.ceil((ms2 - ms1) / 1000);

            var day = Math.floor(sub / (60 * 60 * 24))

            var hours = Math.floor(sub % (60 * 60 * 24) / (60 * 60))

            var minutes = Math.floor(sub % (60 * 60) / (60))

            var seconds = sub % 60
            
            return {day:day,hours:hours,minutes:minutes,seconds:seconds}


        }

        var timee = time(time1, time2)

        document.write(timee)


        console.log(timee);




    </script>

</body>

</html>